//密封
sealed class LicenseStatus02 {
    object UnQualified: LicenseStatus02()
    object Learning: LicenseStatus02()
    class Qualified(val licenseId:String): LicenseStatus02()
}

class Driver02(var status:LicenseStatus02) {
    fun checkLicense():String{
        return when(status) {
            is LicenseStatus02.Learning -> "在学"
            is LicenseStatus02.UnQualified -> "没资格"
            is LicenseStatus02.Qualified -> "有资格，驾驶证编号：${(this.status as LicenseStatus02.Qualified).licenseId}"
        }
    }
}

fun main() {
    val status = LicenseStatus02.Qualified("389")
    val driver = Driver02(status)
    println(driver.checkLicense())
}